package br.com.windnfe.auxiliar;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

import br.com.windnfe.model.Pais;

public class TestaConexao {
	public static void main(String[] args) {
		Configuration configuration = new Configuration();
	    configuration.configure();
		ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
		SessionFactory factory = configuration.buildSessionFactory(serviceRegistry);
		Session session = factory.openSession();
		Pais pais = new Pais();
		pais.setId(1);
		pais.setIbge("123");
		pais.setNome("Brasil");
		pais.setSigla("BR");
		
		Transaction tx = session.beginTransaction();
		session.save(pais);
		tx.commit();
	}
}
